home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.11 Nov 90 / Transition Source / HandleTheMenus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-28  |  4.8 KB  |  245 lines  |  [TEXT/KAHL]

  1. /************************************/
  2. /* File: HandleTheMenus
  3.     Function: Handles menu
  4.     initialization selections. */
  5. /************************************/
  6.  
  7. /************************************/
  8. /* #include files */
  9. #include "Demo.h"
  10.  
  11. /* constants */
  12. /* Menus */
  13. #define AppleMenuID 1001
  14.     #define Item_About_Transition  1
  15.     
  16. #define FileMenuID 1002
  17.     #define Item_Quit  1
  18.     
  19. #define EditMenuID 1003
  20.     #define Item_Undo  1
  21.     #define Item_Cut  3
  22.     #define Item_Copy  4
  23.     #define Item_Paste  5
  24.  
  25. #define OptionsMenuID 1004
  26.     #define DirectionMenuID 10
  27.     
  28.     #define PartitionMenuID 11
  29.     
  30.     #define CopyMenuID 12
  31.  
  32. #define IrisSubMenuID 13
  33. #define FadeSubMenuID 14
  34.  
  35. /* External variables and functions */
  36. extern void D_About(void);
  37.  
  38. /* Global variables and function prototypes */
  39. void InitMyMenus(void);
  40. void HandleMenu(char *doneFlag, short theMenu, short theItem);
  41. void UpdateMenu();
  42.  
  43. MenuHandle AppleMenu, FileMenu, EditMenu, OptionsMenu;
  44. MenuHandle DirectionMenu, PartitionMenu, CopyMenu;
  45. MenuHandle IrisSubMenu, FadeSubMenu;
  46.  
  47. /************************************/
  48. /* void InitMyMenus()
  49.     initializes the menus */
  50. /************************************/
  51. void InitMyMenus()
  52. {
  53. ClearMenuBar();
  54.  
  55. AppleMenu = GetMenu(AppleMenuID);
  56. InsertMenu (AppleMenu,0);
  57. AddResMenu(AppleMenu,'DRVR');
  58.  
  59. FileMenu = GetMenu(FileMenuID);
  60. InsertMenu (FileMenu,0);
  61.  
  62. EditMenu = GetMenu(EditMenuID);
  63. InsertMenu (EditMenu,0);
  64.  
  65. OptionsMenu = GetMenu(OptionsMenuID);
  66. InsertMenu (OptionsMenu,0);
  67.  
  68. DirectionMenu = GetMenu(DirectionMenuID);
  69. InsertMenu (DirectionMenu,-1);
  70.  
  71. PartitionMenu = GetMenu(PartitionMenuID);
  72. InsertMenu (PartitionMenu,-1);
  73.  
  74. CopyMenu = GetMenu(CopyMenuID);
  75. InsertMenu (CopyMenu,-1);
  76.  
  77. IrisSubMenu = GetMenu(IrisSubMenuID);
  78. InsertMenu (IrisSubMenu, -1);
  79.  
  80. FadeSubMenu = GetMenu(FadeSubMenuID);
  81. InsertMenu(FadeSubMenu, -1);
  82.  
  83. DrawMenuBar();
  84. } /* void InitMyMenus() */
  85.  
  86. /************************************/
  87. /* HandleMenu(doneFlag,theMenu,theItem)
  88.     handles menu selection */
  89. /************************************/
  90. void HandleMenu(doneFlag,theMenu,theItem )
  91. char     *doneFlag; 
  92. short   theMenu,theItem;
  93. {
  94. GrafPtr   SavePort;
  95. Str255    DAName;
  96. short     DNA;
  97. char      BoolHolder;
  98. Rect tempRect = {145, 10, 300, 210};
  99.  
  100. switch (theMenu) { /* menu switch */
  101.     case DirectionMenuID:
  102.         GetPort(&SavePort);
  103.         SetPort(MyWindow);
  104.         InvalRect(&tempRect);
  105.         SetPort(SavePort);
  106.         CheckItem(DirectionMenu, dChk, FALSE);
  107.         dChk = theItem;
  108.         CheckItem(DirectionMenu, dChk, TRUE);
  109.         if ((theItem == 7) || (theItem == 8)) {
  110.             CheckItem(CopyMenu, cChk, FALSE);
  111.             cChk = 1;
  112.             wipeMode = srcCopy;
  113.             CheckItem(CopyMenu, cChk, TRUE);
  114.             }
  115.         break;
  116.  
  117.     case PartitionMenuID:
  118.     case IrisSubMenuID:
  119.     case FadeSubMenuID:
  120.         GetPort(&SavePort);
  121.         SetPort(MyWindow);
  122.         InvalRect(&tempRect);
  123.         SetPort(SavePort);
  124.         CheckItem(PartitionMenu, pChk, FALSE);
  125.         CheckItem(IrisSubMenu, pChk, FALSE);
  126.         CheckItem(FadeSubMenu, pChk, FALSE);
  127.         pChk = theItem;
  128.         CheckItem(PartitionMenu, pChk, TRUE);
  129.         CheckItem(IrisSubMenu, pChk, TRUE);
  130.         CheckItem(FadeSubMenu, pChk, TRUE);
  131.         switch (theItem) {
  132.             case 1:
  133.                 wipePart = 1;
  134.                 break;
  135.             case 2:
  136.                 wipePart = 2;
  137.                 break;
  138.             case 3:
  139.                 wipePart = 5;
  140.                 break;
  141.             case 4:
  142.                 wipePart = 10;
  143.                 break;
  144.             default:
  145.                 wipePart = 1;
  146.                 break;
  147.             }
  148.         break;
  149.  
  150.     case CopyMenuID:
  151.         GetPort(&SavePort);
  152.         SetPort(MyWindow);
  153.         InvalRect(&tempRect);
  154.         SetPort(SavePort);
  155.         CheckItem(CopyMenu, cChk, FALSE);
  156.         cChk = theItem;
  157.         CheckItem(CopyMenu, cChk, TRUE);
  158.         switch (theItem) {
  159.             case 1:
  160.                 wipeMode = srcCopy;
  161.                 break;
  162.             case 2:
  163.                 wipeMode = srcOr;
  164.                 break;
  165.             case 3:
  166.                 wipeMode = srcXor;
  167.                 break;
  168.             case 4:
  169.                 wipeMode = srcBic;
  170.                 break;
  171.             case 5:
  172.                 wipeMode = notSrcCopy;
  173.                 break;
  174.             case 6:
  175.                 wipeMode = notSrcOr;
  176.                 break;
  177.             case 7:
  178.                 wipeMode = notSrcXor;
  179.                 break;
  180.             case 8:
  181.                 wipeMode = notSrcBic;
  182.                 break;
  183.             default:
  184.                 wipePart = srcCopy;
  185.                 break;
  186.             }
  187.         break;
  188.  
  189.     case AppleMenuID:
  190.         switch (theItem) {
  191.             case Item_About_Transition:
  192.                 D_About();
  193.                 break;
  194.             default:
  195.                 GetPort(&SavePort);
  196.                 GetItem(AppleMenu, theItem, &DAName);
  197.                 DNA = OpenDeskAcc(DAName);
  198.                 SetPort(SavePort);
  199.                 break;
  200.             }
  201.         break;
  202.  
  203.     case FileMenuID:
  204.         *doneFlag = TRUE;
  205.         break;
  206.  
  207.     case EditMenuID:
  208.         BoolHolder = SystemEdit (theItem - 1);
  209.         break;
  210.  
  211.     default:
  212.         break;
  213.     } /* menu switch */
  214.  
  215. HiliteMenu(0);
  216. } /* HandleMenu(doneFlag,theMenu,theItem) */
  217.  
  218. void UpdateMenu()
  219. {
  220. EnableItem(CopyMenu, 0);
  221. switch (dChk) {
  222.     case 1:
  223.     case 2:
  224.     case 3:
  225.     case 4:
  226.         SetItem(OptionsMenu, 2, "\pPartitions");
  227.         SetItemMark(OptionsMenu, 2, (char) PartitionMenuID);
  228.         break;
  229.     case 5:
  230.         SetItem(OptionsMenu, 2, "\pIris Shape");
  231.         SetItemMark(OptionsMenu, 2, (char) IrisSubMenuID);
  232.         break;
  233.     case 6:
  234.         SetItem(OptionsMenu, 2, "\pFade Type");
  235.         SetItemMark(OptionsMenu, 2, (char) FadeSubMenuID);
  236.         break;
  237.     case 7:
  238.     case 8:
  239.         DisableItem(CopyMenu, 0);
  240.         SetItem(OptionsMenu, 2, "\pPartitions");
  241.         SetItemMark(OptionsMenu, 2, (char) PartitionMenuID);
  242.         break;
  243.     }
  244. }
  245.